package cn.xopencode.appletweb.controller.record.meterroom;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.rpc.meterroom.dto.MeterRoomRecordCreateDTO;
import cn.xopencode.recordservice.rpc.meterroom.dto.MeterRoomRecordPageDTO;
import cn.xopencode.recordservice.rpc.meterroom.dto.MeterRoomRecordUpdateDTO;
import cn.xopencode.recordservice.rpc.meterroom.vo.MeterRoomRecordEmpRelVO;
import cn.xopencode.recordservice.rpc.meterroom.vo.MeterRoomRecordPageVO;
import cn.xopencode.recordservice.rpc.meterroom.vo.MeterRoomRecordUpdateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(tags = "仪表机柜间巡检记录 API")
@RestController
@RequestMapping("/meterroom")
@Validated
public class MeterRoomRecordController {

    /**
     * 根据查询条件分页获取所有的仪表机柜间巡检记录
     * @param pageDTO
     * @return
     */
    @PostMapping("/getAllByQuery")
    @ApiOperation("根据查询条件分页获取所有的仪表机柜间巡检记录")
    public CommonResult<PageResult<MeterRoomRecordPageVO>> getPageMeterRoomRecord(MeterRoomRecordPageDTO pageDTO){
        PageResult<MeterRoomRecordPageVO> result = new PageResult<>();
        List<MeterRoomRecordPageVO> list = new ArrayList<>();

        MeterRoomRecordPageVO vo = new MeterRoomRecordPageVO();
        vo.setInspectionTime(new Date());
        vo.setEmpRels("张三、李四");
        list.add(vo);
        MeterRoomRecordPageVO vo2 = new MeterRoomRecordPageVO();
        vo2.setInspectionTime(new Date());
        vo2.setEmpRels("王一");
        list.add(vo2);

        result.setList(list);
        return null;
    }

    /**
     *  新增仪表机柜间巡检记录
     * @param roomDTO
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("新增仪表机柜间巡检记录")
    public CommonResult<Integer> createMeterRoomRecord(@Valid MeterRoomRecordCreateDTO roomDTO){
        return CommonResult.success(1);
    }

    /**
     *  更新仪表机柜间巡检记录
     * @param roomDTO
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("更新仪表机柜间巡检记录")
    public CommonResult<Integer> updateMeterRoomRecord(@Valid MeterRoomRecordUpdateDTO roomDTO){
        return CommonResult.success(1);
    }

    /**
     * 根据id获取仪表机柜间巡检记录详细
     * @param roomId
     * @return
     */
    @GetMapping("/getById")
    @ApiOperation("根据id获取仪表机柜间巡检记录详细")
    public CommonResult<MeterRoomRecordUpdateVO> getMeterRoomRecordById(String roomId){
        MeterRoomRecordUpdateVO vo = new MeterRoomRecordUpdateVO();
        vo.setInspectionTime(new Date());
        vo.setClean(true);
        vo.setEnTemperature(55.23);
        vo.setGas(false);
        vo.setEnTemperature(35.0);
        vo.setNormal(true);
        vo.setLineTemperature(45.12);
        vo.setId("332343242334");

        List<MeterRoomRecordEmpRelVO> list = new ArrayList<MeterRoomRecordEmpRelVO>();

        MeterRoomRecordEmpRelVO relVO = new MeterRoomRecordEmpRelVO();
        relVO.setEmpId("111");
        relVO.setId("11");
        relVO.setRecordId("332343242334");

        MeterRoomRecordEmpRelVO relVO2 = new MeterRoomRecordEmpRelVO();
        relVO2.setEmpId("222");
        relVO2.setId("22");
        relVO2.setRecordId("332343242334");
        list.add(relVO);
        list.add(relVO2);

        vo.setEmpList(list);
        return CommonResult.success(vo);
    }
}
